package com.longmao.oss.controller;

import com.longmao.commonutils.R;
import com.longmao.oss.service.UploadFileService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author longmao
 * @date 2022/1/25 10:53
 * Content:
 */
@RestController
//@CrossOrigin
@RequestMapping("/eduoss/fileoss")
public class OssController {

    @Autowired
    private UploadFileService uploadFileService;

    /**
     * 上传头像
     * @return
     */
    @ApiOperation(value = "文件上传")
    @PostMapping("/upload")
    public R UploadFileOss(@ApiParam(name = "file", value = "文件", required = true) @RequestBody MultipartFile file) {
        //获取上传文件
        String uploadUrl = uploadFileService.UploadFileOss(file);
        return R.ok().message("文件上传成功").data("url", uploadUrl);
    }
}
